<!DOCTYPE html>
<html lang="en" xmlns:th="http://wwww.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>体检检查</title>
    <script src="../../../static/js/jquery.js"></script>
    <script src="https://lib.baomitu.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://lib.baomitu.com/layui/2.6.5/layui.min.js"></script>
    <link href="https://lib.baomitu.com/layui/2.6.5/css/layui.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../../../css/style.css">
    <link rel="stylesheet" href="../../../css/responsive.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 100px;">
</fieldset>
<section class="appointment-one">

    <div class="container">
        <div class="inner-container wow fadeInUp" data-wow-duration="1s">
            <div>
            <h3 class="appointment-one__title" style="width: 200px;float: left">体检检查</h3><!-- /.appointment-one__title -->
             <button type="submit" onclick="fanHui()" style="background-color: #1e9fff;border:1px #1e9fff;color:#ffffff; width: 150px!important;height: 50px; display: inline-block;float: right;border-radius: 10px">体检信息页面</button>
            <div style="clear:both;"></div>
            </div>
            <div class="col-xl-5 col-lg-6">
                <div>
                    <label class="appointment-one__label">卡号</label>
                <div class="appointment-one__form-group">
                    <div class="appointment-one__icon">
                        <i class="material-icons">person</i>
                    </div><!-- /.appointment-one__icon -->
                    <input type="text" th:value="${visitingCard.Visid}" id="appid" class="name appointment-one__field" placeholder="卡号">
                </div><!-- /.appointment-one__form-group -->
                <button type="submit" onclick="queryAll()" class="add appointment-one__btn thm-btn" style="width: 150px;height: 50px;">查询</button>
                </div>
            </div><!-- /.col-lg-5 -->
             <form class="subscribe appointment-one__form contact-form-vaidated" action="/examine/selectAll" method="get">
                <div class="row align-items-end">
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">姓名</label>
                        <div class="appointment-one__form-group">
                            <div class="appointment-one__icon">
                                <i class="material-icons">person</i>
                            </div><!-- /.appointment-one__icon -->
                            <input type="text" th:value="${user.Uname}" id="uname" class="name appointment-one__field" placeholder="姓名"onfocus=this.blur()>
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-4 col-lg-6">
                        <label class="appointment-one__label">出生日期</label>
                        <div class="appointment-one__form-group">
                            <div class="appointment-one__icon">
                                <i class="material-icons">date_range</i>
                            </div><!-- /.appointment-one__icon -->
                            <input type="date" th:value="${#dates.format(user.Birthday,'yyyy-MM-dd')}" readonly id="birthday" class="appointment-one__field date1" οnfοcus="WdatePicker({minDate:'%y-%M-{%d}'})"  placeholder="出生日期">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-4 -->

                    <div class="col-xl-3 col-lg-6">
                        <label class="appointment-one__label">性别</label>
                        <div class="appointment-one__form-group">
                            <div class="appointment-one__icon">
                                <i class="material-icons">person</i>
                            </div><!-- /.appointment-one__icon -->
                            <div class="appointment-one__switch-wrap">
                                <input type="hidden"   id="sex" readonly>
                                <input type="text" th:value="${user.Sex}" id="sex1" style="display: none">
                                <button  class="sex1 appointment-one__switch"disabled>男</button>
                                <button  class="sex2 appointment-one__switch"disabled>女</button>
                            </div><!-- /.appointment-one__switch-wrap -->
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-3 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">电话号码</label>
                        <div class="appointment-one__form-group">
                            <div class="appointment-one__icon">
                                <i class="material-icons">phone</i>
                            </div><!-- /.appointment-one__icon -->
                            <input  type="text" th:value="${user.Phone}" id="phone" class="phone appointment-one__field" placeholder="输入号码"onfocus=this.blur()>
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">血尿常规</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="urine" name="urine" class="phone appointment-one__field" placeholder="血尿常规">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">肝肾功能</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="function" name="function" class="phone appointment-one__field" placeholder="肝肾功能">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">血压</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="eblood" name="eblood" class="phone appointment-one__field" placeholder="血压">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">体温</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="eschedule" name="eschedule" class="phone appointment-one__field" placeholder="体温">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">心率</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="eheartrate" name="eheartrate" class="phone appointment-one__field" placeholder="心率">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-5 col-lg-6">
                        <label class="appointment-one__label">备注</label>
                        <div class="appointment-one__form-group">
                            <input type="text" id="other" name="other" class="phone appointment-one__field" placeholder="有什么注意">
                        </div><!-- /.appointment-one__form-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-xl-3 col-lg-12">
                        <button type="submit" onclick="Add()" class="add appointment-one__btn thm-btn">提交体检</button>
                    </div><!-- /.col-lg-3 -->
                </div><!-- /.row -->
            </form>
            <div class="result"></div><!-- /.result -->
        </div><!-- /.inner-container -->
    </div><!-- /.container -->
    <span th:value="${dbs}"></span>
</section><!-- /.appointment-one -->
<a href="#" data-target="html" data-target-offset="0" class="scroll-to-target scroll-to-top"><i class="material-icons">keyboard_arrow_up</i></a>
<!-- /.scroll-to-top -->
<script src="../../../js/jquery.js"></script>
<script src="../../../js/bootstrap.bundle.min.js"></script>
<script src="../../../js/bootstrap-select.min.js"></script>
<script src="../../../js/owl.carousel.min.js"></script>
<script src="../../../js/jquery.magnific-popup.min.js"></script>
<script src="../../../js/bootstrap-datepicker.min.js"></script>
<script src="../../../js/jquery.validate.min.js"></script>
<script src="../../../js/wow.min.js"></script>
<script src="../../../js/theme.js"></script>


<script>
    function myDateFomat(t){
        let date=new Date(t);
        let y=date.getFullYear();
        let m=(date.getMonth()+1).toString().padStart(2,"0");
        let d=date.getDate().toString().padStart(2,"0");
        return y+"-"+m+"-"+d;
    }
</script>
<script>
</script>
<script>
    function queryAll(){
        if($("#appid").val()==""){
            layer.open({
                title:'提示'
                ,offset: '200px'
                ,content:'卡号不能为空！'
                ,icon:2
            })
            return false;
        }

        $.ajax({
            type:'get'
            ,url:'/examine/querAll'
            ,data:{appid:$("#appid").val(),uname:$("#uname").val(),birthday:$("#birthday").val(),sex:$("#sex").val(),phone:$("#phone").val()}
            ,success:function (data){
                if(data!=""){
                    $("#uname").val(data[0].uname)
                    $("#birthday").val(myDateFomat(data[0].birthday))
                    if(data[0].sex=="男"){
                        $(".sex1").addClass("active");
                        $(".sex2").removeClass("active");

                    }else{
                        $(".sex1").removeClass("active");

                        $(".sex2").addClass("active");
                    }
                    $("#phone").val(data[0].phone)
                }else{
                    layer.open({
                        title:'提示'
                        ,offset: '150px'
                        ,content:'没有查到该预约的用户！'
                        ,icon:2
                    })
                }
            }
        })
    }
    function fanHui() {
             window.location.href = "http://localhost:8080/ManagementEnd/Home/appexamine.html"
    }
</script>
<script>
    function Add() {
        if($("#appid").val()==""){
            layer.open({
                title:'提示'
                ,offset: '200px'
                ,content:'卡号不能为空！'
                ,icon:2
            })
            return false;
        }
        $.ajax({
            type:"get",
            url:"/examine/add",
            data:{id:$("#id").val(),appid:$("#appid").val(),did:$("#did").val(),edate:new Date(),urine:$("#urine").val(),function:$("#function").val(),eblood:$("#eblood").val(),eschedule:$("#eschedule").val(),eheartrate:$("#eheartrate").val(),other:$("#other").val()},
            success:function (data) {
                    if (data==="true"){
                        layer.open({
                            title:'提示'
                            ,content:'体检完成！'
                            ,icon:1
                            ,yes:function(index,layero){
                                parent.location.reload();//父页面刷新
                                window.location.href = "http://localhost:8080/ManagementEnd/Home/examine.html"
                                varindex=parent.layer.getFrameIndex(window.name);//获取窗口索引
                                parent.layer.close(index);
                        }
                    })
                }
            }
        })
    }
</script>

<script>
    //封装修改体检状态方法
    function  updateStatus(){
        let appid= $("#appid").val();
        $.ajax({
            url: "/examine/update?visid="+appid,
            type: "get",
            contentType:'application/json',
            dataType: 'json',
            success: function (data) {
                if (data.status === 1) {
                    layer.close(layer.index);
                } else {
                }
            },
            error: function () {
                console.log("ajax error");
            }
        });
    }
</script>
<script>
    $(function () {
        if($("#sex1").val()=="男"){
            $(".sex1").addClass("active");
        }else{
            $(".sex2").addClass("active");
        }
    })
</script>
</body>
</html>